package com.will.rest.controller;

import com.will.common.dto.OrderRequest;
import com.will.common.response.AjaxResult;
import com.will.rest.service.IRestOrderService;
import io.seata.core.exception.TransactionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/restOrder")
public class OrderController {

    @Autowired
    private IRestOrderService restOrderService;

    @PostMapping("/handleBusiness")
    public AjaxResult handleBusiness(@RequestBody OrderRequest orderRequest) {
        try {
            return restOrderService.handleBusiness(orderRequest);
        } catch (TransactionException e) {
            return AjaxResult.error("服务器异常");
        }
    }
}
